package com.corpgovernment.supplier.mapper;

import com.corpgovernment.organization.common.mybatis.TkMapper;
import com.corpgovernment.supplier.dto.SupplementInfoDto;
import com.corpgovernment.supplier.dto.SupplierCompanyDto;
import com.corpgovernment.supplier.dto.SupplierCompanyRequest;
import com.corpgovernment.supplier.entity.db.SupplierCompany;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface SupplierCompanyMapper extends TkMapper<SupplierCompany> {
    /**
     * 根据id逻辑删除
     *
     * @param id 主键
     * @return 1成功 0失败
     */
    @Update("update mb_supplier_company set is_deleted = true where id = #{id}")
    int deleteById(@Param("id") Long id);

    /**
     * 根据公司编码和供应商code查询
     *
     * @param companyCode 公司编码
     * @return 供应商公司关联
     */
    List<SupplierCompanyDto> selectByCompanyCode(@Param("companyCode") String companyCode);

    /**
     * 更新sortNum
     */
    @Update("update mb_supplier_company set sort_num = #{supplierCompany.sortNum} where id = #{supplierCompany.id}")
    int updateSortNumById(@Param("supplierCompany") SupplierCompany supplierCompany);

    /**
     * 根据request 查询
     */
    List<SupplierCompanyDto> selectByRequest(@Param("request") SupplierCompanyRequest request);

    List<SupplierCompany> selectProductBySupplierCode(@Param("supplierCode") String supplierCode, @Param("company") String company);

    List<SupplierCompany> selectProductBySupplierCodeAndCompany(@Param("supplierCode") String supplierCode, @Param("company") String company);

    List<SupplementInfoDto> queryEmployeeList(@Param("deptIds") List<String> deptIds, @Param("account") String account, @Param("name") String name, @Param("phone") String phone);

    List<SupplierCompany> querySupplierCompanyBySupplierCode(@Param("supplierCode") String supplierCode);

    List<SupplierCompany> queryCompanySupplierProduct(@Param("orgIds") List<String> orgIds,
        @Param("supplierCode") String supplierCode);

    List<SupplierCompany> queryOrderResultByCompanyList(@Param("companyIdList") List<String> companyIdList, @Param("productType") String productType);
}
